﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetMachineInfo.aspx.cs" Inherits="GetMachineInfo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>获取所需机器</title>

<script language="javascript" type="text/javascript">
        var tmpnum = '0';
        var strparts = '';
        var strpartsid = '';
        var strpartnum = '';
        function addRow() {
            var row1 = idtb.insertRow(idtb.rows.length)
            tmpnum = row1.rowIndex
            if (tmpnum < 6) {
                var td1 = row1.insertCell(0)
                td1.innerHTML = "查看机器名称并获取机器编号："
                var td2 = row1.insertCell(1)
                td2.innerHTML = " <input id='txtPartsName" + tmpnum + "'  type='text'  onclick='showdialog()' readonly='true'></input> "
                
            }
            else {
                idtb.deleteRow(tmpnum)
            }
        }
        function delRow() {
            var sIndex = idtb.rows.length - 1
            if (sIndex > 0)
                idtb.deleteRow(sIndex);
        }
        function showdialog() {
            var returnValue = window.showModalDialog("MachineDialog.aspx", "xx", "dialogWidth=600px;dialogHeight=400px;");
            var txtName = "txtPartsName" + tmpnum;
           
            var txtobject = document.getElementById(txtName);
           
            txtobject.value = returnValue;

        }
        function getParts1() {
            var parts = '';
            for (var i = 1; i <= idtb.rows.length - 1; i++) {
                var txtName = "txtPartsName" + i;
            
                var partsIdobject = document.getElementById(txtName);
                
                var parts = parts + partsIdobject.value + ',' ;
            }
            var hiddenobject = document.getElementById('hidden2');
            hiddenobject.value = parts;
            window.parent.contrliframe();
            alert(parts);
        }
        </script>

</head>
<body>
    <form id="form1" runat="server">
    <div style="background-color: #EFF3FB; font-size:80%">
        <p>
            单击添加图标添加记录<span style="color: Red">(单行记录需确定后进行下一行记录添加，否则返回修改无效)</span></p>
        <table class="style1" id="idtb" border="1px">
            <tr id="idtr">
                <td id="idtd1" class="style2">
                    <%-- <asp:Label ID="Label2" runat="server" Text="查看零件名称并获取零件编号："></asp:Label>--%>
                </td>
                <td id="idtd2">
                    <input id="txtPartsName" runat="server" onclick="showdialog()" readonly="readonly"
                        visible="false" />
                </td>
                <td id="idtd3" class="style2">
                    <%-- <asp:Label ID="Label3" runat="server" Text="需要零件数目："></asp:Label>--%>
                </td>
                <td id="idtd4">
                    <%--   <asp:TextBox ID="txtPartsNum" runat="server"></asp:TextBox>--%>
                </td>
            </tr>
        </table>
        <table width="60%">
            <tr>
                <td align="right">
                    <img src="Image/add.png" alt="添加" onclick="addRow()" height="10px" />
                    <img src="Image/del.png" alt="删除" onclick="delRow()" height="10px" />
                    <input type="button" onclick="getParts1()" value="显示" id="btn" />
                     
                </td>
            </tr>
        </table>
         <asp:HiddenField ID="hidden2" runat="server" />
    </div>
    </form>
</body>
</html>
